package music.player

class Sample(val b:List[Byte]) {
  def +(that:Sample):Sample = Sample(for(i <- 0 to b.length -1) yield (this.b(i) + that.b(i)).toByte)
  def *(m:Double):Sample = Sample(for(i <- 0 to b.length - 1) yield (b(i) * m).toByte);
  def toArray:Array[Byte] = b.toArray[Byte];
}
  
object Sample {
  def apply(b:Byte*):Sample = this.apply(b.toList);
  def apply(b:List[Byte]):Sample = new Sample(b);
  def apply(b:Iterable[Byte]):Sample = this.apply(b.toList);
  def apply(b:Iterable[Byte],from:Int,to:Int):Sample = this.apply(b.slice(from,to).toList);
}